import {ref} from 'vue'
import {defineStore} from 'pinia'
import {getCategoryAPI} from '@/network/layout'

export const useCategoryStore = defineStore('category', () => {
     // 数据请求
     const categoryList = ref([])

     const getCategory = async () => {
        const res = await getCategoryAPI()
         // console.log(res);
         // reactive定义的数据直接赋值，会失去响应式
         categoryList.value = res.result 
         
     }

     return {
        categoryList,
        getCategory
     }
})